﻿using System;

using RoRoWo.Blog.IoC;

namespace Liya.Crm.Core
{
    public class CacheFactory
    {
        static ICache _cache;
        static readonly object padlock = new object();

        /// <summary>
        /// 线程安全的缓存访问
        /// </summary>
        /// <returns></returns>
        public static ICache CacheContext()
        {
            if (_cache == null)
            {
                lock (padlock)//双重锁定，需要创建对象时才加锁
                {
                    if (_cache == null)
                    {
                        _cache = IoCHelper.Resolve<ICache>();
                    }

                }
            }
            return _cache;
        }

    }
}
